<template>
	<view class="reprot ff-padding-bottom-70 ff-color-222 ff-font-14 ff-line-height-1-3">
		<view v-if="reportInfo.status == 6" class="ff-padding-15 ff-color-fff ff-bg-red ff-font-13">
			驳回原因：{{ reportInfo.reportRefuseReason ? reportInfo.reportRefuseReason : '/' }}</view>
		<view class="report-header ff-bg-blue">
			<view class="report-header-content ff-align-items-one ff-flex-between">
				<view class="report-header-content-success ff-color-fff ff-font-18">
					第
					<text class="ff-font-28 ff-padding-left-5 ff-padding-right-6">{{ reportInfo.mainNum }}</text>
					次维保
				</view>
			</view>
		</view>
		<view class="report-content ff-border-radius-10 ff-bg-fff ff-margin-12 ff-font-14">
			<view class="report-content-info-header ff-padding-left-15 ff-padding-right-15 ff-padding-top-15">
				<view class="ff-font-16 ff-font-weight-600 ff-color-000">{{ reportInfo.projectName }}</view>
				<view class="ff-align-items-one ff-flex-wrap">
					<view class="ff-margin-right-10">
						<view v-if="reportInfo.projectStatus == 0" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;已发布</view>
						<view v-if="reportInfo.projectStatus == 1" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;已响应</view>
						<view v-if="reportInfo.projectStatus == 2" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;已确认</view>
						<view v-if="reportInfo.projectStatus == 3" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;进行中</view>
						<view v-if="reportInfo.projectStatus == 4" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;已结束</view>
						<view v-if="reportInfo.projectStatus == 5" class="tips1 ff-font-12">项目状态&nbsp;|&nbsp;待批准</view>
						<view v-if="reportInfo.projectStatus == 6" class="tips5 ff-font-12">项目状态&nbsp;|&nbsp;已解约</view>
						<view v-if="reportInfo.projectStatus == 9" class="tips5 ff-font-12">项目状态&nbsp;|&nbsp;已作废</view>
					</view>
					<view class="ff-margin-right-10">
						<view v-if="reportInfo.status == 0" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;待维保</view>
						<view v-if="reportInfo.status == 1" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;维保中</view>
						<view v-if="reportInfo.status == 2" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;待审核</view>
						<view v-if="reportInfo.status == 3" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;待签发</view>
						<view v-if="reportInfo.status == 5" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;已完成</view>
						<view v-if="reportInfo.status == 6" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;已驳回</view>
						<view v-if="reportInfo.status == 7" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;待指派</view>
						<view v-if="reportInfo.status == 8" class="tips2 ff-font-12">维保状态&nbsp;|&nbsp;待提交</view>
						<view v-if="reportInfo.status == 9" class="tips5 ff-font-12">维保状态&nbsp;|&nbsp;已作废</view>
					</view>
				</view>
				<view class="ff-font-13 ff-color-5C5F65 ff-margin-top-10">
					<u-icon name="map"></u-icon>
					{{ reportInfo.projectAddr }}
				</view>
				<image src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/report-edit.png"
					mode="">
				</image>
			</view>
			<view class="report-content-info-box ff-padding-10" v-if="reportInfo.status == 5">
				<view
					class="report-content-info-box-title ff-font-16 ff-font-weight-600 ff-color-5C5F65 ff-border-radius-5">
					社会单位对本次服务的点评</view>
				<view class="report-content-info-box-content">
					<view class="ff-text-center report-content-info-box-content-result">
						<u-rate :disabled="true" v-model="reportInfo.scoreEvaluate" active-color="#FF6633" size="45"
							inactive-color="#ECECEC" gutter="20"></u-rate>
						<view class="report-content-info-box-content-result-text">
							<u-input :disabled="true" height="190" border="true" v-model="reportInfo.evaluateContent"
								type="textarea" maxlength="-1" />
						</view>
					</view>
				</view>
			</view>
			<view class="report-content-info-box ff-padding-10">
				<view
					class="report-content-info-box-title ff-font-16 ff-font-weight-600 ff-color-5C5F65 ff-border-radius-5">
					项目概况</view>
				<view class="report-content-info-box-content">
					<view v-if="reportInfo.projectUniqueCode"
						class="ff-align-items-one ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">项目ID</view>
						<view class="report-content-info-box-content-right">
							{{ reportInfo.projectUniqueCode }}
						</view>
					</view>
					<view class="ff-align-items-one ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">社会单位</view>
						<view class="report-content-info-box-content-right">{{ reportInfo.companyName }}</view>
					</view>
					<view>
						<view v-if="reportInfo.mainBuilding.buildingNewTypeTopidName">
							<view class="ff-align-items-one ff-padding-left-5 ff-margin-bottom-16">
								<view class="report-content-info-box-content-left">建筑类型</view>
								<view class="report-content-info-box-content-right">
									{{ reportInfo.mainBuilding.buildingNewTypeTopidName }}
								</view>
							</view>
							<view class="ff-align-items-one ff-padding-left-5 ff-margin-bottom-16">
								<view class="report-content-info-box-content-left">建筑物用途</view>
								<view class="report-content-info-box-content-right">
									{{ reportInfo.mainBuilding.buildingNewTypeName || '--' }}
								</view>
							</view>
						</view>
						<view class="ff-align-items-one ff-padding-left-5 ff-margin-bottom-16" v-else>
							<view class="report-content-info-box-content-left">场所类别</view>
							<view class="report-content-info-box-content-right">
								{{ reportInfo.mainBuilding.buildingTypeName }}
							</view>
						</view>
					</view>
					<view class="ff-align-items-one ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">高度(米)</view>
						<view class="report-content-info-box-content-right">{{ reportInfo.mainBuilding.buildingHeight }}
						</view>
					</view>
					<view class="ff-align-items-one ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">地上层数(层)</view>
						<view class="report-content-info-box-content-right">
							{{ reportInfo.mainBuilding.buildingUpLayers }}
						</view>
					</view>
					<view class="ff-align-items-one ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">地下层数(层)</view>
						<view class="report-content-info-box-content-right">
							{{ reportInfo.mainBuilding.buildingDownLayers }}
						</view>
					</view>
					<view class="ff-align-items-one ff-padding-left-5">
						<view class="report-content-info-box-content-left">面积(m²)</view>
						<view class="report-content-info-box-content-right">{{ reportInfo.mainBuilding.buildingArea }}
						</view>
					</view>
				</view>
			</view>
			<view class="report-content-info-box ff-padding-10">
				<view
					class="report-content-info-box-title ff-font-16 ff-font-weight-600 ff-color-5C5F65 ff-border-radius-5">
					维保信息</view>
				<view class="report-content-info-box-content">
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">指派人</view>
						<view class="report-content-info-box-content-right">
							{{ reportInfo.firstAssignmentName || '/' }}&nbsp;{{ reportInfo.firstAssignmentPhone||'' }}
						</view>
						<zb-tooltip placement="left" ref="tooltip13" color="white">
							<view slot="content">
								<view>
									首次指派人：{{ reportInfo.firstAssignmentName || '/' }}&nbsp;{{ reportInfo.firstAssignmentPhone || '' }}
								</view>
								<view v-if="reportInfo.firstAssignmentName != reportInfo.assignName">
									最新指派人：{{ reportInfo.assignName || '/' }}&nbsp;{{ reportInfo.assignPhone || '' }}
								</view>
							</view>
							<u-icon size="28" name="info-circle-fill" color="#3178FF"></u-icon>
						</zb-tooltip>
					</view>
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">指派时间</view>
						<view class="report-content-info-box-content-right">{{ reportInfo.firstAssignmentTime || '/' }}
						</view>
						<zb-tooltip placement="left" ref="tooltip13" color="white">
							<view slot="content">
								<view>首次指派时间：{{ reportInfo.firstAssignmentTime || '/' }}</view>
								<view v-if="reportInfo.firstAssignmentTime != reportInfo.assignTime">
									最新指派时间：{{ reportInfo.assignTime || '/' }}</view>
							</view>
							<u-icon size="28" name="info-circle-fill" color="#3178FF"></u-icon>
						</zb-tooltip>
					</view>
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">维护保养周期</view>
						<view class="report-content-info-box-content-right" v-if="reportInfo.maintenanceType == 1">月维保
						</view>
						<view class="report-content-info-box-content-right" v-if="reportInfo.maintenanceType == 2">季维保
						</view>
						<view class="report-content-info-box-content-right" v-if="reportInfo.maintenanceType == 3">半年维保
						</view>
						<view class="report-content-info-box-content-right" v-if="reportInfo.maintenanceType == 4">年度维保
						</view>
						<view class="report-content-info-box-content-right" v-if="reportInfo.maintenanceType == 5">特殊维保
						</view>
					</view>
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">技术负责人</view>
						<view class="report-content-info-box-content-right" v-if="reportInfo.signers">
							<view v-if="reportInfo.signers.length > 0">
								<view v-for="(item, index) of reportInfo.signers" :key="index">
									{{ item.username }}&nbsp;{{ item.phone }}
								</view>
							</view>
							<view v-else>/</view>
						</view>
					</view>
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">项目负责人</view>
						<view class="report-content-info-box-content-right">
							<view v-for="(item, index) of reportInfo.leaders" :key="index">
								{{ item.username }}&nbsp;{{ item.phone }}
							</view>
						</view>
					</view>
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">执业人员</view>
						<view class="report-content-info-box-content-right">
							<view v-for="(item, index) of reportInfo.operators" :key="index">
								{{ item.username }}&nbsp;{{ item.phone }}
							</view>
						</view>
					</view>
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="report-content-info-box-content-left">开始维保时间</view>
						<view class="report-content-info-box-content-right">{{ reportInfo.startTime || '/' }}</view>
					</view>
					<view class="ff-flex ff-padding-left-5">
						<view class="report-content-info-box-content-left">结束维保时间</view>
						<view class="report-content-info-box-content-right">{{ reportInfo.endTime || '/' }}</view>
					</view>
					<view v-if="reportInfo.cancelReason" class="ff-margin-top-16">
						<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
							<view class="report-content-info-box-content-left">作废人</view>
							<view class="report-content-info-box-content-right">{{ reportInfo.cancelUserName || '/' }}
							</view>
						</view>
						<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
							<view class="report-content-info-box-content-left">作废时间</view>
							<view class="report-content-info-box-content-right">{{ reportInfo.cancelTime || '/' }}
							</view>
						</view>
						<view class="ff-flex ff-padding-left-5">
							<view class="report-content-info-box-content-left">作废原因</view>
							<view class="report-content-info-box-content-right">{{ reportInfo.cancelReason || '/' }}
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-show="textareaState" class="report-content-info-box ff-padding-10">
				<view
					class="report-content-info-box-title ff-font-16 ff-font-weight-600 ff-color-5C5F65 ff-border-radius-5">
					维保概况</view>
				<view class="report-content-info-box-content">
					<view @click="copyReportContent" class="ff-padding-left-5 ff-line-height-1-5 ff-margin-bottom-16">
						<view class="ff-margin-bottom-5 report-content-info-box-content-textareaLeft ">本次维护保养情况简述及结论：
						</view>
						<!-- 字数过多的时候建议把v-model换成:value -->
						<textarea :class="{textareaHeight:autoHeight}" maxlength="-1" :disabled="true"
							:value="reportInfo.reportContent" :auto-height="autoHeight"></textarea>
					</view>
					<view @click="copyReportRepaired" class="ff-padding-left-5 ff-line-height-1-5">
						<view class="ff-margin-bottom-5 report-content-info-box-content-textareaLeft ">已上报管理方待维修问题：
						</view>
						<textarea :class="{textareaHeight:autoHeight}" maxlength="-1" :disabled="true"
							:value="reportInfo.reportRepaired" :auto-height="autoHeight"></textarea>
					</view>
				</view>
			</view>
			<view class="report-content-info-box ff-padding-10">
				<view
					class="report-content-info-box-title ff-font-16 ff-font-weight-600 ff-color-5C5F65 ff-border-radius-5">
					现场维保情况</view>
				<view class="report-content-info-box-content">
					<view @click="fireFacilitiesClick(item.id)"
						v-for="(item, ind) of reportInfo.mainBuilding.mainBuildingFacilities" :key="ind"
						class="ff-padding-left-5 report-content-info-box-content-fireList ff-padding-top-15 ff-padding-bottom-15 ff-align-items-one ff-flex-between">
						<view class="ff-font-15">{{ ind + 1 }}.&nbsp;{{ item.facilitiesTypeName }}</view>
						<view><u-icon name="arrow-right" color="#3178FF" size="32"></u-icon></view>
					</view>
					<view v-if="reportInfo.mainBuilding.mainBuildingFacilities.length < 1"
						class="ff-padding-left-5 ff-padding-bottom-5">
						暂无维保情况
					</view>
				</view>
			</view>
			<view class="report-content-info-box ff-padding-10">
				<view
					class="report-content-info-box-title ff-font-16 ff-font-weight-600 ff-color-5C5F65 ff-border-radius-5">
					附件：测试打印条</view>
				<view>
					<view>
						<u-row gutter="20">
							<u-col span="3" v-for="(item, index) of testAttachs" :key="index">
								<view class="report-content-info-box-content-img ff-margin-bottom-10"
									@click="previewClick(item)">
									<image :src="item" mode="" />
								</view>
							</u-col>
						</u-row>
					</view>
					<view v-if="testAttachs.length < 1" class="ff-padding-left-5 ff-padding-bottom-30">
						暂无附件
					</view>
				</view>
			</view>
			<view v-show="textareaState" class="report-content-info-box ff-padding-10">
				<view
					class="report-content-info-box-title ff-font-16 ff-font-weight-600 ff-color-5C5F65 ff-border-radius-5">
					资料补录</view>
				<!-- 字数过多的时候建议把v-model换成:value -->
				<view class="ff-padding-left-5 ff-margin-bottom-13" v-if="reportInfo.additionalDescription">
					<textarea :class="{textareaHeight:autoHeight}" maxlength="-1" :disabled="true"
						:value="reportInfo.additionalDescription" :auto-height="autoHeight"></textarea>
				</view>
				<u-row gutter="20">
					<u-col span="3" v-for="(item, index) of reportInfo.additionalAttachList" :key="index">
						<view class="report-content-info-box-content-img ff-margin-bottom-10"
							@click="previewSupplementClick(item)">
							<image :src="item" mode="" />
						</view>
					</u-col>
				</u-row>
			</view>
		</view>
		<!-- hasCorrected 是否已勘误:1.未勘误 2.已完成第一次勘误 3.已完成第二次勘误(V3.3.1使用)  || reportInfo.status == 8) -->
		<view class="ff-padding-12 ff-border-radius-10 ff-bg-fff ff-margin-12 ff-flex-between ff-align-items-one"
			v-if="reportInfo.status == 2 && userInfo.id == reportInfo.leaders[0].userId && reportInfo.hasCorrected != 3">
			<view class="ff-font-15 ff-font-weight-600">对数据有歧义？请去勘误</view>
			<view class="corrigendum"><u-button @click="corrigendumClick" type="primary" size="medium">去勘误</u-button>
			</view>
		</view>
		<!-- 按钮区 -->
		<view>
			<cover-view class="report-but ff-flex"
				v-if="reportInfo.status == 2 && userInfo.id == reportInfo.leaders[0].userId">
				<cover-view @click="checkCertificateValid('rejectClick')" class="report-but-reject">驳回</cover-view>
				<cover-view @click="checkCertificateValid('passClick')" class="report-but-pass">通过</cover-view>
			</cover-view>
			<cover-view class="report-but ff-flex"
				v-if="reportInfo.status == 3 && userInfo.id == reportInfo.signers[0].userId">
				<cover-view @click="checkCertificateValid('rejectClick')" class="report-but-reject">驳回</cover-view>
				<cover-view @click="checkCertificateValid('passClick')" class="report-but-pass">签发</cover-view>
			</cover-view>
			<cover-view class="report-but" v-if="reportInfo.status == 5">
				<cover-view class="butPrimary" @click.stop="downloadReport">下载报告书</cover-view>
			</cover-view>
			<cover-view class="report-but"
				v-if="reportInfo.status == 6 && isCheckOperators(userInfo.id, reportInfo.operators)">
				<cover-view @click.stop="writeReport('writeReport')" class="butPrimary">编辑报告书</cover-view>
			</cover-view>
			<cover-view class="report-but"
				v-if="reportInfo.status == 8 && isCheckOperators(userInfo.id, reportInfo.operators)">
				<cover-view class="butPrimary" @click.stop="writeReport('writeReport')">填写报告书</cover-view>
			</cover-view>
		</view>
		<!-- 组件区 -->
		<u-back-top :scrollTop="scrollTopList.scrollTop" top="200" mode="circle" :iconStyle="scrollTopList.iconStyle"
			:customStyle="scrollTopList.customstyle"></u-back-top>
		<u-toast ref="uToast" />
		<f-loading ref="loading" />
		<u-modal v-model="facilitiesModal" @confirm="facilitiesConfirm" title="温馨提示"
			:content-style="{ 'line-height': '1.5' }"
			content="水流指示器、末端试水装置、喷头在维护消防设施的时候是一起维护的，但是在新版报告书中是作为3个项目进行展示。因此导致这三个单独的项目在报告书中没有数据，请重点勘误。" />
		<u-modal v-model="corrigendumOneModal" @confirm="corrigendumOneConfirm" title="温馨提示"
			:content-style="{ 'line-height': '1.5' }" :show-cancel-button="true" @cancel="corrigendumOneConcel"
			content="水流指示器、末端试水装置、喷头在维护消防设施的时候是一起维护的，但是在新版报告书中是作为3个项目进行展示。因此导致这三个单独的项目在报告书中没有数据，请重点勘误。" />
		<u-modal v-model="corrigendumOneModal1" @confirm="corrigendumOneConfirm1" :show-cancel-button="true"
			@cancel="corrigendumOneConcel" title="温馨提示" :content-style="{ 'line-height': '1.5' }"
			content="本次勘误对本次的维保数据没有影响，仅对下次的维保数据有影响。" />
		<u-modal v-model="issueModal" @confirm="issueConfirm" :show-cancel-button="true" @cancel="corrigendumOneConcel"
			title="温馨提示" :content-style="{ 'line-height': '1.5' }"
			content="请确认是否签发报告书？签发后的报告书不可再修改，并会被委托单位与消防救援机构查看。" />
		<!-- 自定义弹窗 -->
		<f-showModel @setVisible="setVisible" :customShowModal.sync="customShowModal" />
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		name: 'Report',
		data() {
			return {
				autoHeight: false, // textarea高度
				textareaState: true, // textarea文本框显/隐
				testAttachs: [], // 附件图片
				facilitiesModal: false, // 消防设施提示维护弹窗显/隐
				corrigendumOneModal: false, // 勘误第一个提示显/隐1
				corrigendumOneModal1: false, // 勘误第二个提示显/隐2
				issueModal: false, // 签发弹窗显/隐
				// 返回顶部组件参数
				scrollTopList: {
					scrollTop: 0,
					iconStyle: {
						fontSize: '32rpx',
						color: '#FFFFFF'
					},
					customstyle: {
						background: '#3B83FE'
					}
				},
				scrollTop: null, // 记录当前的位置
				reportInfo: [], // 报告书内容数据
				// 自定义弹窗内容
				customShowModal: {
					visible: false, // 显隐
					title: '', // 标题,
					content: '', // 内容,
					cancelText: '', // 取消按钮文案,
					confirmText: '', // 确定按钮文案
					messageType: '', // 到期or未到期
					operatorFlag: null, // 单证/双证
				}
			};
		},
		onPageScroll(e) {
			this.scrollTopList.scrollTop = e.scrollTop;
			this.scrollTop = e.scrollTop // 记录当前的位置
		},
		onLoad(e) {
			this.getReportInfo(e.id); // 获取报告书详情数据
			this.getTelInfo() // 获取机型
		},
		computed: {
			// 用户角色状态
			...mapState({
				userInfo: modules => modules.infoList.userInfo
			})
		},
		methods: {
			// 获取当前手机信息
			getTelInfo() {
				let that = this
				uni.getSystemInfo({
					success: function(res) {
						// console.log('当前机型信息', res.deviceBrand)
						if (res.deviceBrand == 'vivo') {
							that.autoHeight = false
						} else {
							that.autoHeight = true
						}
					}
				});
			},
			// 复制维保概况一
			copyReportContent() {
				let that = this
				uni.setClipboardData({
					data: that.reportInfo.reportContent,
					success: function() {}
				});
			},
			// 复制维保概况二
			copyReportRepaired() {
				let that = this
				uni.setClipboardData({
					data: that.reportInfo.reportRepaired,
					success: function() {}
				});
			},
			// 复制项目ID
			copyProjectIdClick(ID) {
				uni.setClipboardData({
					data: ID,
					success: function() {
						uni.getClipboardData({
							success: function() {}
						});
					}
				});
			},
			// 获取报告书详情数据
			async getReportInfo(maintenanceId) {
				this.$refs.loading.openLoading('加载中···');
				const data = await this.$http.post({
					url: `/maintenance/detailV3/${maintenanceId}`
				});
				// console.log('获取报告书详情数据-----', data);
				if (data.code == 200) {
					this.reportInfo = data.data;
					if (this.reportInfo.evaluateContent == null || this.reportInfo.evaluateContent == '') {
						this.reportInfo.evaluateContent = '暂无评价';
					}
					if (!this.reportInfo.reportContent) {
						this.reportInfo.reportContent = '暂无结论';
					}
					if (!this.reportInfo.reportRepaired) {
						this.reportInfo.reportRepaired = '暂无维修问题';
					}
					if (!this.reportInfo.additionalDescription && this.reportInfo.additionalAttachList < 1) {
						this.reportInfo.additionalDescription = '暂无补录';
					}
					this.testAttachs = []
					if (this.reportInfo.testAttachList) {
						this.reportInfo.testAttachList.filter(item => {
							this.testAttachs.push(item.attachUrl) // 给维保附件照片赋值
						})
					}
				}
				this.$refs.loading.closeLoading();
			},
			// 点击跳转消防设施列表页面
			fireFacilitiesClick(id) {
				this.$pageJump.navigateTo(
					'/pages/maintenance/mechanism/home/components/details/components/fireFacilities?id=' + id);
			},
			// 预览测试打印条的照片
			previewClick(img) {
				uni.previewImage({
					urls: this.testAttachs,
					current: img
				});
			},
			// 预览补充资料的照片
			previewSupplementClick(img) {
				uni.previewImage({
					urls: this.reportInfo.additionalAttachList,
					current: img
				});
			},
			// 去勘误
			corrigendumClick() {
				// 维保状态(0.待维保 1.维保中 2.待审核 3.待签发 5.已完成 6.已驳回 7.待指派 8.待提交 9.已作废)
				// 去勘误-----第一次 or 去勘误----第二次  || this.reportInfo.status == 8)
				// 第一次勘误
				if (this.reportInfo.status == 2 && this.reportInfo.hasCorrected == 1 &&
					this.userInfo.id == this.reportInfo.leaders[0].userId) {
					this.textareaState = false
					this.getNeedCorrect() // 判断是否需要勘误
					return;
				}
				// 第二次勘误 || this.reportInfo.status == 8)
				if (this.reportInfo.status == 2 && this.reportInfo.hasCorrected == 2 &&
					this.userInfo.id == this.reportInfo.leaders[0].userId) {
					this.textareaState = false
					this.getNeedCorrect() // 判断是否需要勘误
					return;
				}
			},
			// 判断是否需要勘误
			getNeedCorrect() {
				this.textareaState = false
				this.$refs.loading.openLoading('加载中···');
				this.$http.get({
					url: `/maintenance/ifNeedCorrect/${this.reportInfo.id}`
				}).then(res => {
					// console.log('是否提示勘误------', res);
					this.$refs.loading.closeLoading();
					if (res.code == 200 && res.data) {
						this.textareaState = false
						this.corrigendumOneModal = true; // 多加一个提示：
					} else {
						this.corrigendumOneModal1 = true; // 否则直接提示：本次勘误对本次的维保数据没有影响，仅对下次的维保数据有影响。
					}
				});
			},
			// 去勘误---确认操作1
			corrigendumOneConfirm() {
				this.textareaState = false
				this.corrigendumOneModal1 = true;
			},
			// 去勘误---取消
			corrigendumOneConcel() {
				this.textareaState = true
				uni.pageScrollTo({
					scrollTop: this.scrollTop,
					duration: 1000
				});
			},
			// 去勘误---确认操作2
			corrigendumOneConfirm1() {
				// type:1 ---未勘误 维保前   type:2，维保后
				let paramsInfo = {
					projectId: this.reportInfo.projectId,
					maintenanceId: this.reportInfo.mainBuilding.maintenanceId,
					type: 2
				};
				this.$pageJump.navigateTo(
					'/pages/maintenance/mechanism/home/components/corrigendum/Corrigendum?paramsInfo=' +
					JSON.stringify(paramsInfo));
				this.textareaState = true
			},
			// 下载报告书
			downloadReport() {
				let that = this
				//  || uni.getSystemInfoSync().platform == 'devtools'
				if (uni.getSystemInfoSync().platform == 'windows' || uni.getSystemInfoSync()
					.platform == 'mac' || uni.getSystemInfoSync().platform == 'linux') {
					uni.showModal({
						title: '警告',
						content: '小程序仅支持手机端操作',
						showCancel: false, // 是否显示取消按钮，默认为 true
						confirmColor: '#3178FF',
						success: res => {
							if (res.confirm) {}
						}
					});
					return
				}
				if (that.reportInfo.reportUrl) {
					that.textareaState = false
					that.$refs.loading.openLoading('报告书获取中···');
					uni.downloadFile({
						url: that.reportInfo.reportUrl,
						success(res) {
							// console.log(res)
							let filePath = res.tempFilePath;
							uni.openDocument({
								filePath: filePath,
								showMenu: true,
								success() {
									// console.log('打开文档成功', res);
									that.$refs.loading.closeLoading();
									setTimeout(() => {
										that.textareaState = true
									}, 2500)
								},
								fail() {
									that.$refs.loading.closeLoading();
									that.$refs.uToast.show({
										title: '报告书发生错误，请重新打开',
										type: 'error'
									});
									setTimeout(() => {
										that.textareaState = true
									}, 2500)
								}
							});
						},
						fail() {
							that.$refs.uToast.show({
								title: '报告书发生错误，请重新打开',
								type: 'error'
							});
							that.textareaState = false
							setTimeout(() => {
								that.textareaState = true
							}, 2500)
							that.$refs.loading.closeLoading();
						}
					});
				} else {
					that.$refs.uToast.show({
						title: '报告书生成中，请稍后再试',
						type: 'warning'
					});
					that.textareaState = false
					setTimeout(() => {
						that.textareaState = true
					}, 2500)
				}
			},
			// 驳回报告书
			rejectClick() {
				this.$pageJump.navigateTo('/pages/maintenance/mechanism/home/components/details/rejectReport?id=' +
					this
					.reportInfo.id);
			},
			// 填写or编辑报告书
			writeReport() {
				this.$pageJump.navigateTo('/pages/maintenance/mechanism/home/components/details/editReport?id=' +
					this
					.reportInfo.id);
			},
			// 通过or签发--操作---第一步
			// 检查证书是否到期
			async checkCertificateValid(e) {
				let that = this
				const data = await this.$http.post({
					url: '/maintenance/checkForCertificate?maintenanceId=' + this.reportInfo.mainBuilding
						.maintenanceId
				})
				// console.log('检查证书是否到期', data)
				if (data.code == 200) {
					if (data.data.certificateInValid) {
						this.textareaState = false
						this.customShowModal.visible = true // 显隐
						this.customShowModal.title = '证书已到期' // 标题
						this.customShowModal.content = data.data.msg
					} else {
						if (e == 'passClick') {
							that.passClick() // 签发or通过
						} else if (e == 'rejectClick') {
							that.rejectClick() // 驳回
						} else if (e == 'writeReport') {
							this.writeReport() // 填写报告书
						}
					}
				} else {
					uni.showModal({
						title: '温馨提示',
						content: data.msg,
						confirmColor: '#3178FF',
						showCancel: false,
						success: function(res) {
							if (res.confirm) {
								// console.log('用户点击确定')
							}
						},
					})
				}
			},
			// 关闭弹窗
			setVisible() {
				this.textareaState = true
				this.customShowModal.visible = false // 显隐
			},
			passClick() {
				this.textareaState = false
				this.$refs.loading.openLoading('加载中···');
				this.$http.get({
					url: `/maintenance/ifNeedCorrect/${this.reportInfo.id}`
				}).then(res => {
					// console.log('是否提示勘误------', res);
					this.$refs.loading.closeLoading();
					if (res.code == 200 && res.data) {
						this.textareaState = false
						this.facilitiesModal = true;
					} else {
						this.facilitiesConfirm() // 通过or签发--操作---第二步
					}
				});
			},
			// 通过or签发--操作---第二步
			facilitiesConfirm() {
				// status = 2:待审核状态，跳转页面。status = 3：待签发状态，弹窗
				if (this.reportInfo.status == 2) {
					this.$pageJump.navigateTo(
						'/pages/maintenance/mechanism/home/components/details/appointCharge?id=' +
						this
						.reportInfo.id);
					this.textareaState = true
				} else {
					this.textareaState = false
					this.issueModal = true;
				}
			},
			// 通过or签发--操作---第三步(签发)
			issueConfirm() {
				let that = this
				this.$refs.loading.openLoading('提交中···');
				this.$http.post({
					url: '/serviceOrg/staff/sign/' + this.reportInfo.id
				}).then(res => {
					// console.log('签发返回的数据-----', res);
					this.$refs.loading.closeLoading();
					if (res.code == 200) {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'success'
						});
						that.textareaState = false
						setTimeout(() => {
							that.textareaState = true
							that.getReportInfo(this.reportInfo.id); // 获取报告书详情数据
						}, 2500)
					} else {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error'
						});
						that.textareaState = false
						setTimeout(() => {
							that.textareaState = true
						}, 2500)
					}
				});
			},
			// 循环比较执业人员是否有权限编辑报告书
			isCheckOperators(userId, operatorsId) {
				for (let i = 0; i < operatorsId.length; i++) {
					if (userId == operatorsId[i].userId) {
						return true;
					}
				}
				return false;
			}
		},
		onShareAppMessage() {
			return {
				title: '分享小程序给朋友',
				path: '/pages/homePage/Home'
			};
		}
	};
</script>

<style lang="scss" scoped>
	.tips5 {
		margin-top: 15rpx !important;
		margin-bottom: 0 !important;
	}

	.report {
		&-header {
			height: 350rpx;

			&-content {
				position: relative;

				&-success {
					padding: 50rpx 56rpx;
				}

				image {
					width: 340rpx;
					height: 80rpx;
					position: absolute;
					right: 2%;
					top: 18%;
				}
			}
		}

		&-content {
			.tips1 {
				border: 2rpx solid #2b68ff;
				color: #2b68ff;
				padding: 10rpx 15rpx;
				border-radius: 8rpx;
				margin-top: 15rpx;
			}

			.tips2 {
				border: 2rpx solid #f0403d;
				color: #f0403d;
				padding: 10rpx 15rpx;
				border-radius: 8rpx;
				margin-top: 15rpx;
			}

			margin-top: -190rpx;
			position: relative;

			&-info {
				&-header {
					image {
						width: 230rpx;
						height: 230rpx;
						position: absolute;
						right: 0%;
						top: 0%;
					}
				}

				&-box {
					&-title {
						background: linear-gradient(to right, #eeeeee, #ffffff);
						padding: 24rpx 20rpx 20rpx;
						margin: 24rpx 0 28rpx;
					}

					&-content {
						&-left {
							width: 29%;
							margin-right: 37rpx;
							color: #a6a6a6;
						}

						&-right {
							width: 64%;
						}

						&-textareaLeft {
							color: #a6a6a6;
						}

						&-fireList {
							border-bottom: 2rpx solid #eee;
						}

						&-img {
							image {
								width: 100%;
								height: 140rpx;
							}
						}

						&-result {
							&-fraction {
								color: #adadad;
								margin: 34rpx 0 0;
							}

							&-text {
								margin-top: 38rpx;

								/deep/.u-input__textarea {
									font-size: 30rpx !important;
									color: #222222 !important;
									line-height: 1.3 !important;
									// padding: 0!important;
								}
							}
						}
					}
				}
			}
		}

		&-but {
			padding-bottom: env(safe-area-inset-bottom); // 针对iphone xr等系列的刘海底部屏幕做的适配
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100%;
			background-color: #ffffff;
			z-index: 9990;

			/deep/.u-size-default {
				height: 100rpx !important;
				line-height: 100rpx !important;
			}

			&-reject {
				width: 50%;
				border: 2rpx solid #3178ff;
				background-color: #ffffff;
				color: #3178ff;
				height: 100rpx;
				line-height: 100rpx;
				border-radius: 10rpx;
				text-align: center;
			}

			&-pass {
				width: 50%;
				font-size: 30rpx;
				text-align: center;
				border: 2rpx solid #3178ff;
				background: #3178FF;
				color: #fff;
				height: 100rpx;
				line-height: 100rpx;
				border-radius: 10rpx;
			}
		}
	}



	.corrigendum {
		/deep/.u-btn--primary {
			padding: 0 35rpx !important;
		}
	}

	.codeImg {
		width: 300rpx;
		height: 230rpx;
	}

	.butPrimary {
		font-size: 30rpx;
		text-align: center;
		border: 2rpx solid #3178ff;
		background: #3178FF;
		color: #fff;
		height: 100rpx;
		line-height: 100rpx;
		border-radius: 10rpx;
	}

	textarea {
		width: 98.6%;
		// height: 200rpx;
	}

	.textareaHeight {
		height: 250rpx;
	}
</style>